﻿using ConfigExplorer.CmdClient.Extensions;
using ConfigExplorer.Model;

namespace ConfigExplorer.CmdClient.ModelTransformers
{
    class OrchestrationPortModelTransformer
    {
        internal static OrchestrationPort TransformModel(Microsoft.BizTalk.ExplorerOM.OrchestrationPort omOrchestrationPort)
        {
            var port = new OrchestrationPort();

            port.Name = omOrchestrationPort.Name;

            return port;
        }

        internal static void SetReferences(OrchestrationPort port, BizTalkArtifacts artifacts, Microsoft.BizTalk.ExplorerOM.OrchestrationPort omPort)
        {
            if (omPort.ReceivePort != null)
            {
                port.ReceivePort = artifacts.ReceivePorts[omPort.ReceivePort.Id()];
            }
            else if (omPort.SendPort != null)
            {
                port.SendPort = artifacts.SendPorts[omPort.SendPort.Id()];
            }
        }
    }
}
